home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / ubiquity / check-kernels < prev    next >
Text File  |  2009-10-23  |  3KB  |  95 lines

  1. #! /bin/sh
  2.  
  3. ARCH="$(dpkg --print-architecture)"
  4. SUBARCH="$(archdetect)"
  5. SUBARCH="${SUBARCH#*/}"
  6. CPUINFO=/proc/cpuinfo
  7. UNAME_R="$(uname -r)"
  8. KERNEL_MAJOR="$(echo "$UNAME_R" | cut -d . -f 1,2)"
  9. KERNEL_VERSION="$(echo "$UNAME_R" | cut -d - -f 1)"
  10. KERNEL_ABI="$(echo "$UNAME_R" | cut -d - -f 1,2)"
  11. MACHINE="$(uname -m)"
  12. NUMCPUS=
  13. MEMTOTAL=0
  14. if [ -x /usr/lib/base-installer/dmi-available-memory ]; then
  15.     MEMTOTAL="$(/usr/lib/base-installer/dmi-available-memory)"
  16. fi
  17. if [ "$MEMTOTAL" = 0 ]; then
  18.     MEMTOTAL="$(grep '^MemTotal:[[:space:]]*' /proc/meminfo | \
  19.             sed 's/^MemTotal:[[:space:]]*//; s/ .*//')"
  20. fi
  21.  
  22. if [ -f /usr/lib/ubiquity/base-installer/kernel.sh ]; then
  23.     . /usr/lib/ubiquity/base-installer/kernel.sh
  24. else
  25.     exit 0
  26. fi
  27.  
  28. kernels="$(dpkg-query -f '${status} ${package}\n' -W linux-image-\* | \
  29.         grep '^install ok installed ' | cut -d' ' -f4 | xargs)"
  30.  
  31. flavour="$(arch_get_kernel_flavour || true)"
  32. preferred_kernels="$(arch_get_kernel "$flavour")"
  33. install_new=
  34. compatible=
  35. incompatible=
  36.  
  37. # TODO cjwatson 2009-10-19: Nasty hack for PAE-capable systems; see
  38. # https://launchpad.net/bugs/413135. We should generalise this somehow.
  39. case $preferred_kernels in
  40.     linux-generic-pae*)
  41.     if [ "$(apt-cache search -n '^linux-generic-pae$')" ]; then
  42.         install_new="${install_new:+$install_new }linux-generic-pae"
  43.         for kernel in $kernels; do
  44.             case $kernel in
  45.                 *-generic-pae)
  46.                 compatible="${compatible:+$compatible }$kernel"
  47.                 ;;
  48.                 *)
  49.                 incompatible="${incompatible:+$incompatible }$kernel"
  50.                 ;;
  51.             esac
  52.         done
  53.     fi
  54.     ;;
  55. esac
  56.  
  57. if [ -z "$compatible" ] && [ -z "$install_new" ]; then
  58.     for kernel in $kernels; do
  59.         if arch_check_usable_kernel "$kernel" "$flavour"; then
  60.             compatible="${compatible:+$compatible }$kernel"
  61.         else
  62.             if [ "${kernel%-$UNAME_R}" != "$kernel" ]; then
  63.                 echo 'Would try to remove running kernel;' \
  64.                      'bailing out for sanity' >&2
  65.                 exit 0
  66.             fi
  67.             incompatible="${incompatible:+$incompatible }$kernel"
  68.         fi
  69.     done
  70. fi
  71.  
  72. kernel_to_headers () {
  73.     echo "$1" | sed 's/linux\(-image\|\)/linux-headers/'
  74. }
  75.  
  76. if [ -z "$compatible" ] && [ -z "$install_new" ]; then
  77.     # We must be wrong. After all, we got this far ...
  78.     echo 'No usable kernel found; assuming foreign package naming' >&2
  79. else
  80.     mkdir -p /var/lib/ubiquity
  81.     for kernel in $install_new; do
  82.         echo "$kernel" >>/var/lib/ubiquity/install-kernels
  83.         kernel_to_headers "$kernel" >>/var/lib/ubiquity/install-kernels
  84.     done
  85.     for kernel in $compatible; do
  86.         apt-install "$kernel" "$(kernel_to_headers "$kernel")"
  87.     done
  88.     for kernel in $incompatible; do
  89.         echo "$kernel" >> /var/lib/ubiquity/remove-kernels
  90.         kernel_to_headers "$kernel" >>/var/lib/ubiquity/remove-kernels
  91.     done
  92. fi
  93.  
  94. exit 0
  95.